/*
    XTU OJ: 1430
    Link: https://acm.xtu.edu.cn/exam/index.php/problem/exam_read/id/1430
    by: fifth_light
*/

#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main(void) {
    int t;
    scanf("%d", &t);
    for(int i = 0; i < t; i++) {
        // 数组开大一点，省下减'a'成本
        int chars[256] = {0};
        // 读取第一个字符并忽略
        getchar();
        int last = 0;
        while (1) {
            int ch = getchar();
            if (ch < 'a' || ch > 'z') {
                break;
            }
            chars[last] = 1;
            // 永远只处理上一个字符，从而忽略最后一个字符
            last = ch;
        }
        
        getchar();
        int match = 0;
        last = 0;
        while (1) {
            int ch = getchar();
            if (ch < 'a' || ch > 'z') {
                break;
            }
            if (match) {
                continue;
            }
            if (last != 0 && chars[last]) {
                match = 1;
            }
            last = ch;
        }
        
        puts(match ? "Yes" : "No");
    }
    return 0;
}
